package
{
	import flash.display.BitmapData;
	import flash.display.Graphics;
	import flash.geom.ColorTransform;
	import flash.geom.Matrix;
	import flash.geom.Rectangle;

	public class MapObjectBitmap extends MapObject
	{
		public var bmData:BitmapData;
		public override function GetType():uint
		{
			return MapObject.BitmapObject;
		}
		public function MapObjectBitmap(id:uint,path:String)
		{
			super(id,path);
		}
		public override function SetDisplayData(o:Object):void
		{
			bmData = BitmapData(o);
		}
		public override function GetDisplayData():Object
		{
			return bmData;	
		}
		public override function Draw(g:Graphics, x:int,y:int):void
		{
			var matrix:Matrix = new Matrix();
			matrix.translate(x, y);
			g.beginBitmapFill(bmData,matrix);
			g.drawRect(x,y,bmData.width,bmData.height);
			g.endFill();
		}
		public override function DrawHighlight(g:Graphics, x:int,y:int):void
		{
			var matrix:Matrix = new Matrix();
			matrix.translate(x, y);
			var bmHL:BitmapData = bmData.clone();
			var cTransform:ColorTransform = new ColorTransform();
			cTransform.color = 200;
			bmHL.colorTransform(new Rectangle(0,0,bmHL.width,bmHL.height),cTransform);
			g.beginBitmapFill(bmHL,matrix);
			g.drawRect(x,y,bmHL.width,bmHL.height);
			g.endFill();
		}
		public override function GetWidth():uint
		{
			return bmData.width;
		}
		public override function GetHeight():uint
		{
			return bmData.height;	
		}
	}
}